package com.zhongge.arrayOJ;

import java.util.Arrays;

/**
 * @ClassName Merge
 * @Description TODO 合并两个有序数组
 * @Author 笨忠
 * @Date 2025/8/7 21:42
 * @Version 1.0
 */
public class Merge {
    public static void merge(int[] nums1, int m, int[] nums2, int n){

        //我先将nums2全部合并到num1中
        int t = m;
        for (int l = 0; l < n; l++) {
            nums1[t++] = nums2[l];
        }
        //然后借助排序API
        Arrays.sort(nums1);

    }

    public static void main(String[] args) {
        int[] nums1 = {1,2,4,5,6,0};
        int[] nums2 = {3};

        merge(nums1, 5, nums2, 1);

        for (int k = 0; k < 6; k++) {
            System.out.print(nums1[k] + " ");
        }
        System.out.println();
    }
}
